import requests
from 歌曲下载 import download_music

# 请求的URL
url = 'https://tonzhon.com/api.php'

# 要发送的数据
data = {
    'types': 'search',
    'count': 10,
    'source': 'netease',
    'pages':2,
    'name':'刀郞'
}

# 发起POST请求
response = requests.post(url, data=data)
json_data = response.json()
# 音乐文件的URL
music_url = "https://music.163.com/song/media/outer/url?id=" # 1804320463.mp3
# 保存到本地的文件名
local_filename = "E:/个人资料/歌曲/" # 踏山河.mp3
for i in json_data:
    download_music(music_url+str(i['id'])+'.mp3',local_filename+i['artist'][0][0]+'-'+i['name']+'.mp3')
